<?php

/*
Минус — &#8722;
Бесконечность — &#8734;
Объединение — &#8746;
Пересечение — &#8745;
Разность —
Вычитание —
Пустое множество — &#8709;


?	EMPTY SET (8709)	solidus in circle; empty set; null set; diameter	math
?	ELEMENT OF (8712)	set membership; member	math
?	ELEMENT OF (8712)	set membership; member	math
?	SUBSET OF (8834)	subset; proper inclusion in set; is implied by	math
?	SUPERSET OF (8835)	superset; properly includes in set; implies	math
?	NOT A SUBSET OF (8836)	not subset; non-proper inclusion in set	math
?	NOT A SUPERSET OF (8837)	not superset; does not properly include in set	math
?	SUBSET OF OR EQUAL TO (8838)	subset, equals; identity or inclusion in set	math
?	SUPERSET OF OR EQUAL TO (8839)	superset, equals; ident.with or contains as subset	math
?	NEITHER A SUBSET OF NOR EQUAL TO (8840)	not subset, equals; not contained in or not eql to	math
?	NEITHER A SUPERSET OF NOR EQUAL TO (8841)	not superset, equals; does not contain as subset	math
?	SUBSET OF WITH NOT EQUAL TO (8842)	subset, not equals	math
?	SUPERSET OF WITH NOT EQUAL TO (8843)	superset, not equals	math
?	MULTISET (8844)
?	MULTISET MULTIPLICATION (8845)	union, with dot	unknown
?	MULTISET UNION (8846)	u plus B: plus sign in union	math

?	SET MINUS (8726)	/setminus B: reverse solidus	math
?	INTERSECTION (8745)	prod. of intrsctn of cl./sets; vee; small intrsctn	math
?	UNION (8746)	sum or union of classes or sets; logical sum	math
?	DOT MINUS (8760)	minus with dot above; symmetric difference	math


?	NOT AN ELEMENT OF (8713)	not an element of; is not a member of	math
?	CONTAINS AS MEMBER (8715)	contains; owns; includes	math
?	DOES NOT CONTAIN AS MEMBER (8716)	does not contain as a member	math
+	PLUS SIGN (43)	=plus sign B:	math

¬	NOT SIGN (172)	logical not sign	math

±	PLUS-MINUS SIGN (177)	plus or minus sign	math

?	DIVISION SIGN (247)	division sign	math

?	GREEK NUMERAL SIGN (884)

?	FOR ALL (8704)	inverted capital A; for all	math
?	COMPLEMENT (8705)	complement	math
?	PARTIAL DIFFERENTIAL (8706)	curly d; differential -- Greek --	math
?	THERE EXISTS (8707)	reversed cap. E; there exists; at least one exists	math
?	THERE DOES NOT EXIST (8708)	not rev. cap. E; not exists; there does not exist	math
?	EMPTY SET (8709)	solidus in circle; empty set; null set; diameter	math
?	INCREMENT (8710)
?	NABLA (8711)	differential vector; nabla;	math
?	ELEMENT OF (8712)	set membership; member	math
?	NOT AN ELEMENT OF (8713)	not an element of; is not a member of	math
?	SMALL ELEMENT OF (8714)		math
?	CONTAINS AS MEMBER (8715)	contains; owns; includes	math
?	DOES NOT CONTAIN AS MEMBER (8716)	does not contain as a member	math
?	SMALL CONTAINS AS MEMBER (8717)		math
?	END OF PROOF (8718)
?	N-ARY PRODUCT (8719)	product operator	math
?	N-ARY COPRODUCT (8720)	inverted product (cumulator)	math
?	N-ARY SUMMATION (8721)	summation operator	math
?	MINUS SIGN (8722)	minus sign	text
?	MINUS-OR-PLUS SIGN (8723)	minus or plus sign	math
?	DOT PLUS (8724)	plus sign, dot above; direct sum	math
?	DIVISION SLASH (8725)
?	SET MINUS (8726)	/setminus B: reverse solidus	math
?	ASTERISK OPERATOR (8727)	mid asterisk	math
?	RING OPERATOR (8728)	centered circle; composite function; convolution	math
?	BULLET OPERATOR (8729)	centered small circle, filled	math
?	SQUARE ROOT (8730)	root; radical sign	math
?	CUBE ROOT (8731)
?	FOURTH ROOT (8732)
?	PROPORTIONAL TO (8733)	is proportional to; varies as	math
?	INFINITY (8734)	infinity sign	math
?	RIGHT ANGLE (8735)	right (90 degree) angle; factorial sign	math
?	ANGLE (8736)	angle	math
?	MEASURED ANGLE (8737)	angle-measured	math
?	SPHERICAL ANGLE (8738)	spherical angle	math
?	DIVIDES (8739)	divides; mid (Height of capital I)	math
?	DOES NOT DIVIDE (8740)	not mid	math
?	PARALLEL TO (8741)	parallel to (height of capital I)	math
?	NOT PARALLEL TO (8742)	not parallel	math
?	LOGICAL AND (8743)	logical and; small infinum; wedge	math
?	LOGICAL OR (8744)	logical or; small supremum	math
?	INTERSECTION (8745)	prod. of intrsctn of cl./sets; vee; small intrsctn	math
?	UNION (8746)	sum or union of classes or sets; logical sum	math
?	INTEGRAL (8747)	integral operator	math
?	DOUBLE INTEGRAL (8748)	double integral operator	math
?	TRIPLE INTEGRAL (8749)	/iiint triple integral operator	math
?	CONTOUR INTEGRAL (8750)	contour integral; circuital integral	math
?	SURFACE INTEGRAL (8751)	surface integral	math
?	VOLUME INTEGRAL (8752)	volume integral	math
?	CLOCKWISE INTEGRAL (8753)	clockwise integral	math
?	CLOCKWISE CONTOUR INTEGRAL (8754)	contour integral, clockwise	math
?	ANTICLOCKWISE CONTOUR INTEGRAL (8755)	contour integral, anti-clockwise	math
?	THEREFORE (8756)	therefore	math
?	BECAUSE (8757)	because	math
?	RATIO (8758)	/ratio	unknown
?	PROPORTION (8759)	four dots in square; as	math
?	DOT MINUS (8760)	minus with dot above; symmetric difference	math
?	EXCESS (8761)
?	GEOMETRIC PROPORTION (8762)	geometric properties	math
?	HOMOTHETIC (8763)	homothetic	math
?	TILDE OPERATOR (8764)	similar; equivalent to; varies linearly with	math
?	REVERSED TILDE (8765)	reverse mainline tilde; reverse similar	math
?	INVERTED LAZY S (8766)	** most positive	math
?	WREATH PRODUCT (8768)	wreath product	math
?	NOT TILDE (8769)	not similar; not equivalent to	math
?	MINUS TILDE (8770)	** equal, similar	math
?	ASYMPTOTICALLY EQUAL TO (8771)	similar, equals; asymptotically equal to	math
?	NOT ASYMPTOTICALLY EQUAL TO (8772)	not similar, equals; not asymptotically equal to	math
?	APPROXIMATELY EQUAL TO (8773)	congruent with; similar to	math
?	APPROXIMATELY BUT NOT ACTUALLY EQUAL TO (8774)	approximately but not actually equal to	math
?	NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO (8775)	not congruent with; neither appr. nor act. equal	math
?	ALMOST EQUAL TO (8776)	approximate; asymptotic	math
?	NOT ALMOST EQUAL TO (8777)	not approximate; not asymptotic to	math
?	ALMOST EQUAL OR EQUAL TO (8778)	approximate, equals; asymptotic or equal to	math
?	TRIPLE TILDE (8779)	triple tilde;approximately identical to	math
?	ALL EQUAL TO (8780)	reverse congruent	math
?	EQUIVALENT TO (8781)	cupcap; asymptotically equal to	math
?	GEOMETRICALLY EQUIVALENT TO (8782)	bumpy equals; geometrically equiv. to; appr. equal	math
?	DIFFERENCE BETWEEN (8783)	bumpy equals, equals; approximately equal to	math
?	APPROACHES THE LIMIT (8784)	equals, dot above; approaches the limit	math
?	GEOMETRICALLY EQUAL TO (8785)	equals,even dots; approximately equal	math
?	APPROXIMATELY EQUAL TO OR THE IMAGE OF (8786)	equals, falling dots; appr. equal to; image of	math
?	IMAGE OF OR APPROXIMATELY EQUAL TO (8787)	rising dots equal R: eq, rising dots	math
?	COLON EQUALS (8788)	colon, equals; is defined as	text
?	EQUALS COLON (8789)	equals, colon; defines	math
?	RING IN EQUAL TO (8790)	circle in equals sign	math
?	RING EQUAL TO (8791)	circeq R: circle, equals	math
?	CORRESPONDS TO (8792)
?	ESTIMATES (8793)	estimates; corresponds to	math
?	EQUIANGULAR TO (8794)	equiangular; equals with hacek	math
?	STAR EQUALS (8795)	equal, asterisk above	math
?	DELTA EQUAL TO (8796)	triangle, equal; equal by definition	math
?	EQUAL TO BY DEFINITION (8797)
?	MEASURED BY (8798)
?	QUESTIONED EQUAL TO (8799)	equal, questionmark	math
?	NOT EQUAL TO (8800)	not equal to	math
?	IDENTICAL TO (8801)	equivalent; identical with; triple equals	math
?	NOT IDENTICAL TO (8802)	not equivalent, not identical with	math
?	STRICTLY EQUIVALENT TO (8803)
?	LESS-THAN OR EQUAL TO (8804)	less than or equal	math
?	GREATER-THAN OR EQUAL TO (8805)	greater than or equal to	math
?	LESS-THAN OVER EQUAL TO (8806)	less than or (double) equal	math
?	GREATER-THAN OVER EQUAL TO (8807)	greater than or double equal to	math
?	LESS-THAN BUT NOT EQUAL TO (8808)	less than but not (double) equal to	math
?	GREATER-THAN BUT NOT EQUAL TO (8809)	greater than but not (double) equal to	math
?	MUCH LESS-THAN (8810)	much less than (double)	math
?	MUCH GREATER-THAN (8811)	much greater than (double)	math
?	BETWEEN (8812)	between	math
?	NOT EQUIVALENT TO (8813)	not asymptotically equivalent	math
?	NOT LESS-THAN (8814)	not less than	math
?	NOT GREATER-THAN (8815)	not greater than	math
?	NEITHER LESS-THAN NOR EQUAL TO (8816)	neither less than nor equal to, slanted	math
?	NEITHER GREATER-THAN NOR EQUAL TO (8817)	neither greater than nor equal to, slanted	math
?	LESS-THAN OR EQUIVALENT TO (8818)	less than or similar to; less, approximate	math
?	GREATER-THAN OR EQUIVALENT TO (8819)	greater than or similar to; greater than approx.	math
?	NEITHER LESS-THAN NOR EQUIVALENT TO (8820)	neither less than nor equivalent to	math
?	NEITHER GREATER-THAN NOR EQUIVALENT TO (8821)	neither greater than nor equivalent to	math
?	LESS-THAN OR GREATER-THAN (8822)	less than or greater than	math
?	GREATER-THAN OR LESS-THAN (8823)	greater than or less than	math
?	NEITHER LESS-THAN NOR GREATER-THAN (8824)	neither less than nor greater than	math
?	NEITHER GREATER-THAN NOR LESS-THAN (8825)	neither greater than nor less than	math
?	PRECEDES (8826)	precedes; has lower rank than; is dominated by	math
?	SUCCEEDS (8827)	succeeds; has higher rank than; dominates	math
?	PRECEDES OR EQUAL TO (8828)	curly prec. equal; has rank lower than or equal to	math
?	SUCCEEDS OR EQUAL TO (8829)	succ. ,curly eq; has rank higher than or equal to	math
?	PRECEDES OR EQUIVALENT TO (8830)	precedes, similar; dominance; contained in, equiv.	math
?	SUCCEEDS OR EQUIVALENT TO (8831)	succeeds, similar	math
?	DOES NOT PRECEDE (8832)	does not precede	math
?	DOES NOT SUCCEED (8833)	does not succeed	math
?	SUBSET OF (8834)	subset; proper inclusion in set; is implied by	math
?	SUPERSET OF (8835)	superset; properly includes in set; implies	math
?	NOT A SUBSET OF (8836)	not subset; non-proper inclusion in set	math
?	NOT A SUPERSET OF (8837)	not superset; does not properly include in set	math
?	SUBSET OF OR EQUAL TO (8838)	subset, equals; identity or inclusion in set	math
?	SUPERSET OF OR EQUAL TO (8839)	superset, equals; ident.with or contains as subset	math
?	NEITHER A SUBSET OF NOR EQUAL TO (8840)	not subset, equals; not contained in or not eql to	math
?	NEITHER A SUPERSET OF NOR EQUAL TO (8841)	not superset, equals; does not contain as subset	math
?	SUBSET OF WITH NOT EQUAL TO (8842)	subset, not equals	math
?	SUPERSET OF WITH NOT EQUAL TO (8843)	superset, not equals	math
?	MULTISET (8844)
?	MULTISET MULTIPLICATION (8845)	union, with dot	unknown
?	MULTISET UNION (8846)	u plus B: plus sign in union	math

?	SQUARE IMAGE OF (8847)	square subset; image of	math
?	SQUARE ORIGINAL OF (8848)	square superset; original of	math
?	SQUARE IMAGE OF OR EQUAL TO (8849)	square subset, equals	math
?	SQUARE ORIGINAL OF OR EQUAL TO (8850)	square superset, equals	math
?	SQUARE CAP (8851)	square intersection	math
?	SQUARE CUP (8852)	square union	math
*/


define('_Tp_element', '#integer');

class Object
{
    public $namespace = 'http://www.kadm.com.ua/XMLSchama/Object';

    function toString()
    {
        return '';
    }

    function toHTML()
    {
        return '';
    }

    function toXML()
    {
        return '<obj></obj>';
    }
}

abstract class _Set  extends Object
{

    private static $_Tp_element = '#integer';

    function __construct() {}

    static final function is_element_type($o)
    {
        return _is_a($o, $this->_Tp_element);
    }

    abstract function has_a($element);

    function toHTML() {}
}

class EmptySet extends _Set
{
    function has_a($element)
    {
        return false;
    }

    function toHTML()
    {
        return '&#8709;';
    }
}


class FullSet extends _Set
{
    function has_a($element)
    {
        return true;
    }

    function toHTML()
    {
        return '&#8469;';//'(&#8722;&#8734;,&nbsp;&#8734;)';
    }
}

class SingleSet extends _Set
{

    protected $element;

    function __construct($element)
    {
        if (_is_a($element, _Tp_element)) {
            $this->element = $element;
        } else {
            throw new Exception("Xernya, rebyata!");
        }
    }

    function has_a($element)
    {
        if (_is_a($element, _Tp_element)) {
            return eq($this->element, $element);
        } else {
            throw "Xernya, rebyata!";
        }
    }

    function element()
    {
        return $this->element;
    }

    function toHTML()
    {
        $element_str = '';
        if (! _is_system(_Tp_element) && is_a($this->element, "Object")) {
            $element_str = $this->element->toHTML();
        } else {
            $element_str = str_replace('-', '&#8722;', "{$this->element}");
        }
        return '{' . $element_str . '}';
    }
}

class RangeSet extends _Set
{

    protected $begin;
    protected $end;

    function __construct($begin, $end)
    {
        if (_is_a($begin, _Tp_element) && _is_a($end, _Tp_element)) {
            if ($begin < $end) {
                $this->begin = $begin;
                $this->end = $end;
            } else {
                throw "Xernya, rebyata!";
            }
        } else {
            throw new Exception("Xernya, rebyata!");
        }
    }

    function toHTML()
    {
        $begin_str = '';
        $end_str   = '';
        if (! _is_system(_Tp_element) && is_a($this->element, "Object")) {
            $begin_str = $this->begin->toHTML();
            $end_str   = $this->end->toHTML();
        } else {
            $begin_str = str_replace('-', '&#8722;', "{$this->begin}");
            $end_str   = str_replace('-', '&#8722;', "{$this->end}");
        }
        return '[' . $begin_str . ', ' . $end_str . ']';
    }

    function has_a($element)
    {
        return le($this->begin, $element) && ge($this->end, $element);
    }

    function begin()
    {
        return $this->begin;
    }

    function end()
    {
        return $this->end;
    }

    function size()
    {
        return $this->end - $this->begin + 1;
    }
}

class GtSet extends _Set
{

    protected $point;

    function __construct($point)
    {
        if (_is_a($point, _Tp_element)) {
            $this->point = $point;
        } else {
            throw "Xernya, rebyata!";
        }
    }

    function toHTML()
    {
        $point_str = '';
        $end_str   = '';
        if (! _is_system(_Tp_element) && is_a($this->element, "Object")) {
            $point_str = $this->point->toHTML();
        } else {
            $point_str = str_replace('-', '&#8722;', "{$this->point}");
        }
        return '[' . $point_str . ', &#8734;)';
    }

    function has_a($element)
    {
        return le($this->point, $element);
    }

    function point()
    {
        return $this->point;
    }

}

class LtSet extends _Set
{

    protected $point;

    function __construct($point)
    {
        if (_is_a($point, _Tp_element)) {
            $this->point = $point;
        } else {
            throw "Xernya, rebyata!";
        }
    }

    function toHTML()
    {
        $point_str = '';
        $end_str   = '';
        if (! _is_system(_Tp_element) && is_a($this->element, "Object")) {
            $point_str = $this->point->toHTML();
        } else {
            $point_str = str_replace('-', '&#8722;', "{$this->point}");
        }
        return '(&#8722;&#8734;, ' . $point_str . ']';
    }

    function has_a($element)
    {
        return ge($this->point, $element);
    }

    function point()
    {
        return $this->point;
    }

}


/*
Set (set)
List (list)
Union (union)
Intersect (intersect)
Set inclusion (in)
Set exclusion (notin)
Subset (subset)
Proper Subset (prsubset)
Not Subset (notsubset)
Not Proper Subset (notprsubset)
Set Difference(setdiff)
Cardinality(card)
Cartesian product(cartesianproduct)

?	DOUBLE-STRUCK CAPITAL Z (8484)	the ring of integers	math
*/
class EnumSet extends _Set
{

    protected $elements;

    function __construct()
    {
        $this->elements = array ();
        $num = func_num_args();
        if ($num < 1) {
            throw "Xernya, rebyata!";
        }
        $this->elements[] = func_get_arg(0);
        for ($i = 1; $i < $num; $i++) {
            if (_is_a(func_get_arg($i), _Tp_element)) {
                if (func_get_arg($i) <= $this->elements[$i - 1]) {
                    //throw "Xernya, rebyata!";
                }
                $this->elements[] = func_get_arg($i);
            } else {
                throw "Xernya, rebyata!";
            }
        }
    }

    function toHTML()
    {
        $result = '';
        $exists_method = ! _is_system(_Tp_element) && is_a($this->element, "Object");
        $not_first = false;
        for ($i = 0; $i < $this->size(); $i++) {
            if ($not_first) {
                $result .= ' &#8746; ';
            }
            $result .= '{';
            if ($exists_method) {
                $result .= $this->elements[$i]->toHTML();
            } else {
                $element = $this->elements[$i];
                $result .= str_replace('-', '&#8722;', "{$element}");
            }
            $result .= '}';
            $not_first = true;
        }
        return $result;
    }

    function has_a($element)
    {
        for ($i = 0; $i < count($this->elements); $i++) {
            if (eq($this->elements[$i], $element)) {
                return true;
            }
        }
        return false;
    }

    function size()
    {
        return count($this->elements);
    }

    function element($index)
    {
        if (($index < 0) && ($index >= count($this->elements))) {
            throw "Xernya, rebyata!";
        }
        return $this->elements[$index];
    }
}

?>